import { Entity, PrimaryGeneratedColumn, Column,ManyToMany,JoinTable } from 'typeorm'
import {Posts} from './Posts'

@Entity({ name: 'tags' })
export class Tags {
  @PrimaryGeneratedColumn({
    type: 'int',
    name: 'id',
    comment: '主键id'
  })
  id: number

  @Column({
    type: 'varchar',
    nullable: false,
    unique: true,
    comment: 'tag名称'
  })
  name: string

  @ManyToMany(type=>Posts,post=>post.tags)
  @JoinTable({name:'tags_posts'}) //指定中间表名
  posts:Posts[]
}